<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="http://unpkg.com/vue"></script>
    <script>
        window.onload =function(){
            // 注册
            Vue.component('my-component', {
                template: '<div>A custom component!</div>'
            });
            Vue.component('simple-counter', {
                template: '<button v-on:click="counter += 1">{{ counter }}</button>',
                // 技术上 data 的确是一个函数了，因此 Vue 不会警告，
                // 但是我们返回给每个组件的实例却引用了同一个 data 对象
                data: function () {
                    return {
                        counter:0
                    }
                }
            });
            Vue.component('child', {
                // camelCase in JavaScript
                props: ['myMessage'],
                template: '<span>{{ myMessage }}</span>',


            })
            // 创建根实例
            new Vue({
                el: '#example-2',
                data:{
                    parentMsg:''

                }
            })

        }
    </script>
</head>
<body>
<div id="example-2">
    <my-component></my-component>
    <simple-counter></simple-counter>
    <simple-counter></simple-counter>
    <simple-counter></simple-counter>
    <div>
        <input v-model="parentMsg">
        <br>
        <child v-bind:my-message="parentMsg"></child>
    </div>

</div>
</body>
</html>